<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:awc="clr-namespace:Assergs.Windows.Controls"
	xmlns:aw="clr-namespace:Assergs.Windows"
	>

	<SolidColorBrush x:Key="ForegroundBrush" Color="{x:Static aw:ToolWindowTabItemContainerPallet.Foreground}"/>
	<SolidColorBrush x:Key="GlyphBrush" Color="{x:Static aw:ToolWindowTabItemContainerPallet.Glyph}"/>
	<SolidColorBrush x:Key="NormalBorderBrush" Color="{x:Static aw:ToolWindowTabItemContainerPallet.NormalBorder}"/>
	<SolidColorBrush x:Key="BodyBackgroundBrush" Color="{x:Static aw:ToolWindowTabItemContainerPallet.BodyBackground}"/>
	
	<LinearGradientBrush x:Key="ButtonBackgroundBrush" StartPoint="0.5,0" EndPoint="0.5,1">
		<GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonBackground1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonBackground2}" Offset="0.4"/>
        <GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonBackground3}" Offset="0.4"/>
        <GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonBackground4}" Offset="1"/>
	</LinearGradientBrush>
	
	<LinearGradientBrush x:Key="ButtonLightBackgroundBrush" StartPoint="0.5,0" EndPoint="0.5,1">
		<GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonLightBackground1}" Offset="0"/>
		<GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonLightBackground2}" Offset="0.4"/>
		<GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonLightBackground3}" Offset="0.4"/>
		<GradientStop Color="{x:Static aw:ToolWindowTabItemContainerPallet.ButtonLightBackground4}" Offset="1"/>
	</LinearGradientBrush>
	
	<DrawingImage x:Key="TabItemCloseButtonImage">
		<DrawingImage.Drawing>
			<GeometryDrawing Brush="{DynamicResource GlyphBrush}"
				Geometry="M0,0L3,0L4.5,2L6,0L9,0L6,3L6,5L9,8L6,8L4.5,6L3,8L0,8L3,5L3,3Z" />
		</DrawingImage.Drawing>
	</DrawingImage>
	
	<DrawingImage x:Key="TabItemRestoreButtonImage">
		<DrawingImage.Drawing>
			<GeometryDrawing>
				<GeometryDrawing.Pen>
					<Pen Thickness="1.5" Brush="{DynamicResource GlyphBrush}"/>
				</GeometryDrawing.Pen>
				<GeometryDrawing.Geometry>
					<!--<PathGeometry Figures="M 0 4 L 0 0 L 4 0 M 0 0 L 6 6 M 10 0 L 10 10 L 0 10"/>-->
					<PathGeometry Figures="M 0 10 L 0 0 L 10 0 M 10 6 L 10 10 L 6 10 M 4 4 L 10 10"/>
				</GeometryDrawing.Geometry>
			</GeometryDrawing>
		</DrawingImage.Drawing>
	</DrawingImage>

   
    <Style x:Key="TabItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="3,3,3,1"
                               StrokeThickness="1"
                               Stroke="Black"
                               StrokeDashArray="1 2"
                               SnapsToDevicePixels="true"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="TabItemDisabledBackground" Color="#F4F4F4"/>
    <SolidColorBrush x:Key="TabItemHotBorderBrush" Color="#3C7FB1"/>
    <SolidColorBrush x:Key="TabItemDisabledBorderBrush" Color="#FFC9C7BA"/>
    
    <Style x:Key="{x:Type awc:ToolWindowTabItemContainer}" TargetType="{x:Type awc:ToolWindowTabItemContainer}">
		<Setter Property="FocusVisualStyle" Value="{DynamicResource TabItemFocusVisual}"/>
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}"/>
        <Setter Property="Padding" Value="6,1,6,1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
        <Setter Property="Background" Value="{DynamicResource ButtonBackgroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type awc:ToolWindowTabItemContainer}">
                    <Grid SnapsToDevicePixels="true">
                    
                        <Border Name="Bd"
								Padding="{TemplateBinding Padding}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}"
                                BorderThickness="1,1,1,0">
                                <StackPanel Orientation="Horizontal">
                                
									<Image Name="IconImage" Source="{TemplateBinding Icon}" Width="16" Height="16" Stretch="UniformToFill" Margin="0,0,4,0" />
                                
									<ContentPresenter Name="Content"
                                              ContentSource="Header"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                              HorizontalAlignment="{Binding Path=HorizontalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
                                              VerticalAlignment="{Binding Path=VerticalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
                                              RecognizesAccessKey="True"/>    
									
									<awc:ImageButton Name="MaximizeButton" 
										Command="{x:Static awc:ToolWindowTabItemContainer.TabRestoreCommand}" 
										Visibility="Collapsed" 
										IsToolStyle="True" 
										Margin="8,0,0,0" 
										Width="18" Height="18"
										ImageSource="{DynamicResource TabItemRestoreButtonImage}"/>
									
									<awc:ImageButton Name="CloseButton" 
										Command="{x:Static awc:ToolWindowTabItemContainer.TabCloseCommand}" 
										Visibility="Collapsed" 
										IsToolStyle="True" 
										Margin="0" 
										Width="18" Height="18"
										ImageSource="{DynamicResource TabItemCloseButtonImage}"/>
									        
                                </StackPanel>
                            
                        </Border>
                        
                    </Grid>
                    <ControlTemplate.Triggers>
						<Trigger Property="Icon" Value="{x:Null}">
                            <Setter TargetName="IconImage" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ButtonLightBackgroundBrush}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource BodyBackgroundBrush}"/>
                            <Setter TargetName="MaximizeButton" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="CloseButton" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="false"/>
                                <Condition Property="IsMouseOver" Value="true"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource TabItemHotBorderBrush}"/>
                        </MultiTrigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="Bd" Property="BorderThickness" Value="1,0,1,1"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="Bd" Property="BorderThickness" Value="1,1,0,1"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="Bd" Property="BorderThickness" Value="0,1,1,1"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                                <Condition Property="TabStripPlacement" Value="Top"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-2,-2,-2,-1"/>
                            <Setter TargetName="Content" Property="Margin" Value="0,0,0,1"/>                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                                <Condition Property="TabStripPlacement" Value="Bottom"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-2,-1,-2,-2"/>
                            <Setter TargetName="Content" Property="Margin" Value="0,1,0,0"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                                <Condition Property="TabStripPlacement" Value="Left"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-2,-2,-1,-2"/>
                            <Setter TargetName="Content" Property="Margin" Value="0,0,1,0"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                                <Condition Property="TabStripPlacement" Value="Right"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-1,-2,-2,-2"/>
                            <Setter TargetName="Content" Property="Margin" Value="1,0,0,0"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource TabItemDisabledBackground}"/>
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource TabItemDisabledBorderBrush}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>